package com.mlnx.push.websocket.server.topic;

/**
 * Created by amanda.shan on 2019/4/10.
 */
public class DeviceTopic extends Topic {

    private String deviceId;

    public DeviceTopic(TopicType topicType, String deviceId) {
        super(topicType);
        this.deviceId = deviceId;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    @Override
    public boolean equals(Object obj) {

        if (super.equals(obj)) {
            DeviceTopic topic = (DeviceTopic) obj;
            return (topic.deviceId.equals(deviceId) || deviceId.equals("*"));
        }
        return false;
    }

    @Override
    public String toString() {
        return topicType.toString()+":"+deviceId;
    }
}
